﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Reflection;
using System.IO;

namespace LIK.NetAssemblyChecker
{
    internal class NetAssembly : AssemblyObject
    {

        Assembly _foundDllAssembly;

        internal NetAssembly(string file):base(file, null)
        {
            _foundDllAssembly = System.Reflection.Assembly.ReflectionOnlyLoadFrom(file);
        }


        internal TreeNode GetTreeNode(bool includedepandant)
        {
            string nodename = String.Format("{0} [{1}]", Name, _foundDllAssembly.ImageRuntimeVersion);
            TreeNode tr = base.GetTreeNode(nodename, _foundDllAssembly);
            Commons.CheckRunTime(_foundDllAssembly.ImageRuntimeVersion);
            if (includedepandant)
            {
                AssemblyName[] aNames = _foundDllAssembly.GetReferencedAssemblies();

                foreach (AssemblyName an in aNames)
                {
                    tr.Nodes.Add((new ReferencedAssembly(an, this)).GetTreeNode());
                }
            }
            return tr;
        }


    }
}
